<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title></title>
    <style>
        .container {
            height: 85%;
            width: 97%;
            position: fixed;
            overflow-x: auto;
            overflow-y: scroll;
        }

        .btn-hide {
            display: none;
        }

        * {
            moz-user-select: -moz-none;
            -moz-user-select: none;
            -o-user-select: none;
            -khtml-user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }
    </style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 业务数据管理 <span
        class="c-gray en">&gt;</span> PMC数据维护 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                                 href="javascript: f_getinfo(); " title="刷新">
    <i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container" style="padding-top: 0">
    <div id="fshowzd" style="font-size: 20px; color: brown">当前月份：</div>
    <div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-top: 0">
        <label id="xzyf" style=" margin-top: 6px; margin-right: 6px" class="l">选择月份：
            <select id="jflx" style="width: 180px; font-size: 16px">
            </select>
        </label>
        <span class="l">
            <a href="javascript:" onclick="f_add()" class="btn btn-primary radius" id="add"><i class="Hui-iconfont">&#xe600;</i> 新增PMC记录</a>
        </span>
        <%--        <span class="r" style="padding-top: 6px;">共有数据：<strong id="count">${map.get("db2")[0].VALUE01}</strong> 条</span>--%>
    </div>
    <div class="container">
        <table style="table-layout:fixed; width: 10px; word-break:break-all;" class="table table-border table-bordered table-bg table-hover table-sort table-responsive" id="tablelist">
            <thead>
            <tr class="text-c">
                <th style="display: none">系统编号</th>
                <th style="width: 45px;">编号</th>
                <th style="width: 95px; background:#e2efda">母卷规格</th>
                <th style="width: 65px;  background:#e2efda">客户</th>
                <th style="width: 80px; background:#e2efda">规格</th>
                <th style="width: 50px;  background:#e2efda">孔型</th>
                <th style="width: 80px; background:#e2efda">下月预计量</th>
                <th style="width: 70px; background:#e2efda">管芯</th>
                <th style="width: 80px; background:#e2efda">纸箱</th>
                <th style="width: 110px; background:#e2efda">发货时间</th>
                <th style="width: 70px; background:#ddebf7">母卷需求</th>
                <th style="width: 70px; background:#ddebf7">管芯需求</th>
                <th style="width: 70px; background:#ddebf7">纸箱需求</th>
                <th style="width: 150px; background:#ddebf7">生产时间安排</th>
                <th style="width: 60px; background:#ddebf7">机台</th>
                <th style="width: 100px; background:#ddebf7">操作者</th>
                <th style="width: 100px; background:#ddebf7">生产计划/已完成</th>
                <th style="width: 80px; background:#ddebf7">生产未完成</th>
                <th></th>
            </tr>
            </thead>
            <tbody id="datalist">
            </tbody>
        </table>

    </div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

    let is_right = "0";
    let ii_page = 1;   //--上一页下一页的计数器
    let ii_row = 20;   //--每页显示的记录数
    let ii_count = 0;
    let is_dangyue = "";  //--当前所选择的月份
    var obj = $("#jflx");
    let oldobj;
    let oldcor;
    let ii = 1;

    $(document).ajaxComplete(function (event, xhr, settings) {
        //从http头信息取出 在filter定义的sessionstatus，判断是否是 timeout
        if (xhr.getResponseHeader("sessionstatus") === "timeout") {
            //从http头信息取出登录的url ＝ loginPath
            if (xhr.getResponseHeader("loginPath")) {
                window.location.replace(xhr.getResponseHeader("loginPath"));
            }
        }
    });

    $(document).ready(function () {
        f_init();
    });

    obj.on('change', function () {
        //判断是否选取prompt属性，无返回值；
        if ($(this).val()) {
            var selectText = $(this).find('option:selected').text();
            is_dangyue = $(this).val();
            $("#fshowzd").text("当前月份：" + is_dangyue);
            ii = 1;
            f_getinfo();
        }
    });

    function f_init() {
        var ls_opid = "${sessionOpid}";
        $.ajax({
            type: 'post',
            url: 'com',
            data: {
                CMD: 'BD',
                VALUE01: ls_opid
            },
            async: false,
            success: function (data) {
                let jsonobj = JSON.parse(data);

                //--获取权限代号，依据权限对可操作的部分进行限定
                is_right = jsonobj.db2[0].VALUE02.toString();
                if (jsonobj.db2[0].VALUE02.toString() !== "2") {
                    $("#add").addClass("btn-hide");
                }

                let json1 = jsonobj.db1;
                if (json1.length > 0) {
                    obj.append("<option value=''> </option>");
                    for (var key in json1) {
                        var ls_value = json1[key].VALUE01.toString();
                        obj.append("<option value='" + ls_value + "'>" + ls_value + "</option>");
                    }
                }
            },
            error: function () {
                layer.msg('网络异常错误', {icon: 1, time: 1000});
            }
        })
    }

    function f_getinfo() {
        let ls_opid = "${sessionOpid}";
        if (!ls_opid) {
            layer.msg("请重新登录系统！", {icon: 0, time: 1000});
            return;
        }

        ii = 1;
        $.ajax({
            type: 'post',
            url: 'com',
            data: {
                URL: '',
                CMD: 'AJ',
                VALUE01: ls_opid,
                VALUE02: is_dangyue
            },
            async: false,
            success: function (data) {
                var jsonobj = JSON.parse(data);

                let c_table = $("#datalist");
                c_table.html("");
                let str = "";
                let json1 = jsonobj.db1;
                let li_count = Object.keys(json1).length;
                let li_num = 1;
                for (let key in json1) {
                    if (li_num < li_count) {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json1[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_mjgg(this)\">" + json1[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_kh(this)\">" + json1[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_gg(this)\">" + json1[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_kx(this)\">" + json1[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_xyyjl(this)\">" + json1[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_gx(this)\">" + json1[key].VALUE07.toString() + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_zx(this)\">" + json1[key].VALUE08.toString() + "</td>" +
                            "<td style='background:#e2efda; border-bottom: lightsalmon solid 1px' ondblclick=\"f_fhsj(this)\">" + json1[key].VALUE09.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE10.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE11.toString() + "</td>" +
                            "<td style='background:#ddebf7; ' >" + json1[key].VALUE12.toString() + "</td>" +
                            "<td style='background:#ddebf7; border-bottom: lightsalmon solid 1px' ondblclick=\"f_scsjap(this)\">" + json1[key].VALUE13.toString() + "</td>" +
                            "<td style='background:#ddebf7; border-bottom: lightsalmon solid 1px' ondblclick=\"f_jt(this)\">" + json1[key].VALUE14.toString() + "</td>" +
                            "<td style='background:#ddebf7; border-bottom: lightsalmon solid 1px' ondblclick=\"f_czz(this)\">" + json1[key].VALUE15.toString() + "</td>" +
                            "<td style='background:#ddebf7; border-bottom: lightsalmon solid 1px' ondblclick=\"f_scjhywc(this)\">" + json1[key].VALUE16.toString() + "</td>" +
                            "<td style='background:#ddebf7; border-bottom: lightsalmon solid 1px' ondblclick=\"f_scwwc(this)\">" + json1[key].VALUE17.toString() + "</td>" +
                            "</tr>";
                        li_num++;
                    } else {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json1[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE07.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE08.toString() + "</td>" +
                            "<td style='background:#e2efda; color: brown; font-weight: bold'>" + json1[key].VALUE09.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE10.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE11.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE12.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE13.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE14.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE15.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE16.toString() + "</td>" +
                            "<td style='background:#ddebf7; color: brown; font-weight: bold'>" + json1[key].VALUE17.toString() + "</td>" +
                            "</tr>";
                    }
                    ii++;
                }

                //------------遍历第二张表，库管表
                for (let i = 0; i < 1; i++) {
                    str += "<tr class='text-c'>" +
                        "<td >" + parseInt(ii) + "</td>" +
                        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                        "</tr>"
                    ii++;
                }

                str += "<tr class='text-c'>" +
                    "<td >" + parseInt(ii) + "</td>" +
                    "<td style='background:#FFFAF0; font-weight: bold '>规格</td>" +
                    "<td style='background:#FFFAF0; font-weight: bold '>孔型</td>" +
                    "<td style='background:#FFFAF0; font-weight: bold '>成品库存</td>" +
                    "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                    "</tr>"
                ii++;

                let json2 = jsonobj.db2;
                li_count = Object.keys(json2).length;
                li_num = 1;
                for (let key in json2) {
                    if (li_num < li_count) {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json2[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#FFFAF0; '>" + json2[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0; '>" + json2[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#FFFAF0; border-bottom: lightsalmon solid 1px' ondblclick=\"f_cpkc(this)\">" + json2[key].VALUE04.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                        li_num++;
                    } else {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json2[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold'>" + json2[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold'>" + json2[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold' >" + json2[key].VALUE04.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                    }
                    ii++;
                }

                //------------遍历第三张表 采购表
                for (let i = 0; i < 1; i++) {
                    str += "<tr class='text-c'>" +
                        "<td >" + parseInt(ii) + "</td>" +
                        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                        "</tr>"
                    ii++;
                }

                str += "<tr class='text-c'>" +
                    "<td >" + parseInt(ii) + "</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>母卷规格</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>母卷库存量</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>月度总需求</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>已采购</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>预计到货日期</td>" +
                    "<td style='background:#e2d0f6; font-weight: bold '>缺口</td>" +
                    "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                    "</tr>"
                ii++;

                let json3 = jsonobj.db3;
                li_count = Object.keys(json3).length;
                li_num = 1;
                for (let key in json3) {
                    if (li_num < li_count) {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json3[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2d0f6; '>" + json3[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0;  border-bottom: lightsalmon solid 1px' ondblclick=\"f_mjkcl(this)\">" + json3[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2d0f6; ' >" + json3[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  border-bottom: lightsalmon solid 1px' ondblclick=\"f_ycg(this)\">" + json3[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  border-bottom: lightsalmon solid 1px' ondblclick=\"f_yjdhrq(this)\">" + json3[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  border-bottom: lightsalmon solid 1px' ondblclick=\"f_qk(this)\">" + json3[key].VALUE07.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                        li_num++;
                    } else {
                        str += "<tr class='text-c'>" +
                            "<td style='display: none'>" + json3[key].VALUE01.toString() + "</td>" +
                            "<td >" + parseInt(ii) + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold'>" + json3[key].VALUE02.toString() + "</td>" +
                            "<td style='background:#FFFAF0;  color: brown; font-weight: bold'>" + json3[key].VALUE03.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE04.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE05.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE06.toString() + "</td>" +
                            "<td style='background:#e2d0f6;  color: brown; font-weight: bold' >" + json3[key].VALUE07.toString() + "</td>" +
                            "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                            "</tr>";
                    }
                    ii++;
                }

                for (let i = 0; i < 1; i++) {
                    str += "<tr class='text-c'>" +
                        "<td >" + parseInt(ii) + "</td>" +
                        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
                        "</tr>"
                    ii++;
                }

                c_table.html(str);
            },
            error: function () {
                layer.msg('网络异常错误', {icon: 1, time: 1000});
            }
        })
    }

    /*母卷规格*/
    function f_mjgg(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        let ls_gg = $(obj).parent().find('td').eq(4).text() || "";

        if (ls_gg.length === 0) {
            layer.msg('请先选择规格参数!', {icon: 0, time: 2000});
            return;
        }

        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            btn: ['确定', '关闭'],
            shade: 0.4,
            title: "选择母卷规格",
            content: "w_sel_mjgg.jsp?VALUE01=" + li_id,
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "MJGG",
                        VALUE03: res.mjgg,
                        VALUE04: is_dangyue
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            layer.msg('数据保存完毕!', {icon: 6, time: 1500});
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*客户*/
    function f_kh(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            btn: ['确定', '关闭'],
            shade: 0.4,
            title: "选择客户信息",
            content: "w_sel_kh.jsp",
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "KH",
                        VALUE03: res.khnbbh
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            layer.msg('数据保存完毕!', {icon: 6, time: 1500});
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*规格*/
    function f_gg(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            btn: ['确定', '关闭'],
            title: "选择规格",
            content: "w_sel_gg.jsp?VALUE01=" + li_id,
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "GG",
                        VALUE03: res.ggms,
                        VALUE04: is_dangyue
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            let ls_tmp = json1[0].VALUE02.toString() || '';
                            if (ls_tmp.length > 0) {
                                layer.msg(ls_tmp, {icon: 0, time: 3000});
                            } else {
                                layer.msg('数据保存完毕!', {icon: 6, time: 2000});
                            }
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 3000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*孔型*/
    function f_kx(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            btn: ['确定', '关闭'],
            shade: 0.4,
            title: "选择孔型信息",
            content: "w_sel_kx.jsp",
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "KX",
                        VALUE03: res.kx,
                        VALUE04: is_dangyue
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            layer.msg('数据保存完毕!', {icon: 6, time: 1500});
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*下月预计量*/
    function f_xyyjl(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        let li_val = $(obj).parent().find('td').eq(6).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入下月预计量",
            content: "w_sel_xyyjl.jsp?VALUE01=" + li_id + "&VALUE02=" + li_val + "&VALUE03=" + is_dangyue,
        });
    }

    /*管芯*/
    function f_gx(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        let ls_gg = $(obj).parent().find('td').eq(4).text() || "";
        if (ls_gg.length === 0) {
            layer.msg('请先选择规格参数!', {icon: 0, time: 2000});
            return;
        }
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            btn: ['确定', '关闭'],
            title: "请选择管芯",
            content: "w_sel_gx.jsp?VALUE01=" + li_id,
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "GX",
                        VALUE03: res.gxms
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            layer.msg('数据保存完毕!', {icon: 6, time: 1500});
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*纸箱*/
    function f_zx(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            btn: ['确定', '关闭'],
            title: "请选择纸箱",
            content: "w_sel_zx.jsp?VALUE01=" + li_id,
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "ZX",
                        VALUE03: res.zx
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            layer.msg('数据保存完毕!', {icon: 6, time: 2000});
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*发货时间*/
    function f_fhsj(obj) {
        if (is_right !== "2")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入发货时间",
            content: "w_sel_fhsj.jsp?VALUE01=" + li_id
        });
    }

    /*生产时间安排*/
    function f_scsjap(obj) {
        if (is_right !== "3")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入生产时间安排",
            content: "w_sel_scsjap.jsp?VALUE01=" + li_id
        });
    }

    /*机台*/
    function f_jt(obj) {
        if (is_right !== "3")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            btn: ['确定', '关闭'],
            title: "请选择机台",
            content: "w_sel_jt.jsp?VALUE01=" + li_id,
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "JT",
                        VALUE03: res.jt
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            layer.msg('数据保存完毕!', {icon: 6, time: 2000});
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*操作者*/
    function f_czz(obj) {
        if (is_right !== "3")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            btn: ['确定', '关闭'],
            title: "请选择操作者",
            content: "w_sel_czz.jsp?VALUE01=" + li_id,
            yes: function (index) {
                //当点击‘确定’按钮的时候，获取弹出层返回的值
                let res = window["layui-layer-iframe" + index].callbackdata();
                //打印返回的值，看是否有我们想返回的值。
                $.ajax({
                    type: 'post',
                    url: 'com',
                    async: false,
                    data: {
                        URL: '',
                        CMD: 'AK',
                        VALUE01: li_id,
                        VALUE02: "CZZ",
                        VALUE03: res.czz
                    },
                    success: function (data) {
                        let jsonobj = JSON.parse(data);
                        let json1 = jsonobj.db1;
                        if (json1[0].VALUE01.toString() === 'ZZ00') {
                            //此处请求后台程序，下方是成功后的前台处理……
                            f_getinfo();
                            layer.msg('数据保存完毕!', {icon: 6, time: 2000});
                        } else {
                            layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000, area: ['auto', '65px']}, function () {
                                let index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                    },
                    error: function () {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    }
                })
                //最后关闭弹出层
                layer.close(index);
            }
        });
    }

    /*生产计划已完成*/
    function f_scjhywc(obj) {
        if (is_right !== "3")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入生产计划已完成",
            content: "w_sel_scjhywc.jsp?VALUE01=" + li_id
        });
    }

    /*生产未完成*/
    function f_scwwc(obj) {
        if (is_right !== "3")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入生产未完成",
            content: "w_sel_scwwc.jsp?VALUE01=" + li_id
        });
    }

    /*成品库存*/
    function f_cpkc(obj) {
        if (is_right !== "4")
        {
            return;
        }
        f_docolor(obj);
        let ls_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入成品库存",
            content: "w_sel_cpkc.jsp?VALUE01=" + ls_id
        });
    }

    /*母卷库存量*/
    function f_mjkcl(obj) {
        if (is_right !== "4")
        {
            return;
        }
        f_docolor(obj);
        let ls_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入成品库存",
            content: "w_sel_mjkcl.jsp?VALUE01=" + ls_id
        });
    }

    /*已采购数量*/
    function f_ycg(obj) {
        if (is_right !== "5")
        {
            return;
        }
        f_docolor(obj);
        let ls_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入已采购",
            content: "w_sel_ycg.jsp?VALUE01=" + ls_id
        });
    }

    /*预计到货日期*/
    function f_yjdhrq(obj) {
        if (is_right !== "5")
        {
            return;
        }
        f_docolor(obj);
        let li_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入预计到货日期",
            content: "w_sel_yjdhrq.jsp?VALUE01=" + li_id
        });
    }

    /*缺口*/
    function f_qk(obj) {
        if (is_right !== "5")
        {
            return;
        }
        f_docolor(obj);
        let ls_id = $(obj).parent().find('td').eq(0).text();
        layer.open({
            type: 2,
            area: [800 + 'px', 600 + 'px'],
            fix: false, //不固定
            maxmin: false,
            shade: 0.4,
            title: "输入缺口数量",
            content: "w_sel_qk.jsp?VALUE01=" + ls_id
        });
    }

    /*增加一笔记录*/
    function f_add() {
        if (is_dangyue.length === 0) {
            layer.msg('请先选择月份!', {icon: 0, time: 2000});
            return;
        }
        layer.confirm('确认要新增PMC记录吗？', function (index) {
            $.ajax({
                type: 'post',
                url: 'com',
                async: false,
                data: {
                    URL: '',
                    CMD: 'AI',
                    VALUE01: is_dangyue
                },
                success: function (data) {
                    let jsonobj = JSON.parse(data);
                    let json1 = jsonobj.db1;
                    if (json1[0].VALUE01.toString() === 'ZZ00') {
                        //此处请求后台程序，下方是成功后的前台处理……
                        layer.msg('新PMC数据生成完毕!', {icon: 1, time: 1500});
                        f_getinfo();
                    } else {
                        layer.msg(json1[0].VALUE02.toString(), {icon: 2, time: 2000}, function () {
                            let index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }
                },
                error: function () {
                    layer.msg('网络异常错误', {icon: 1, time: 1000});
                }
            });
        });
    }

    /*设置颜色*/
    function f_docolor(obj) {
        if (typeof (oldobj) !== "undefined") {
            $(oldobj).css("background-color", oldcor);
            oldobj = obj;
            oldcor = $(obj).css("background-color");
            $(obj).css("background-color", "#FFE7BA");
        } else {
            oldobj = obj;
            oldcor = $(obj).css("background-color");
            $(obj).css("background-color", "#FFE7BA");
        }
    }
</script>
</body>
</html>
